<?php echo $this->title($this->pageTitle) ?>

<?php if (count($this->data['reviews'])): ?>

<div class="review-customer-average">
    <div class="head">
        <h3><?php echo $this->translate('community')->__("Reviews by %s", $this->customer) ?></h3>
    </div>
    <div class="content">
        <div class="statistics">
            <p><?php echo $this->translate('community')->__("Overall: %s %s", "<span>{$this->paging['count']}</span>", $this->paging['count'] > 1 ? 'reviews' : 'review') ?></p>
        </div>
        <div class="average-mark">
        <h6><?php echo $this->translate('community')->__('Average user ratings') ?>:</h6>
        <?php if (isset($this->average_customer_ratings[$this->customerId])): ?>
            <?php echo $this->ratings($this->average_customer_ratings[$this->customerId], '#', false) ?>
        <?php endif ?>
        </div>
    </div>
</div>

<?php echo $this->render('review/list/toolbar.phtml') ?>
<form id="form-compare" method="post" action="<?php echo $this->href('review/compare') ?>">
<ol class="review-list">
<?php foreach ($this->data['reviews'] as $review) : 
$productUrl = $this->hurl(array(
    'product' => array('value' => $review['product_id'], 'seo' => $review['product_key_word']),
    'controller' => 'catalog',
    'action' => 'product'
), false, true);
$author = empty($review['author']) ? 'Guest' : $review['author'];
?>
<li class="review">
    <div class="product-image">
        <a href="<?php echo $productUrl;?>" 
            title="<?php echo $this->escape($review['product_image_title']) ?>"
        ><?php
            echo $this->imager('/product' . $review['product_image_thumbnail'], array(
                'width'  => $this->config()->image->product->widthSmall,
                'height' => $this->config()->image->product->heightSmall,
                'alt' => $this->escape($review['product_image_title']),
                'seo' => $review['product_image_seo_name']
            ));
        ?></a>
        <?php if (isset($this->average_ratings[$review['product_id']])): ?>
            <?php echo $this->ratings($this->average_ratings[$review['product_id']], $this->href("review/product/{$review['product_key_word']}")) ?>
        <?php endif ?>
    </div>
    <div class="product-compare">
        <input type="checkbox" name="product_id[]"
            value="<?php echo $review['product_id'] ?>"
            title="<?php echo $this->translate('community')->__('Select to compare') ?>"/>
    </div>
    <div class="product-common">
        <?php echo $this->price($review['product_price'], 
            !empty($review['product_price_discount']) ? 
                $review['product_price_discount'] : false
        ) ?>
        <?php if (Ecart::single('community/review')->canAdd()) : ?>
        <a href="<?php echo $this->href("review/product/{$review['product_key_word']}#form-review") ?>"
            rel="nofollow"
            title="<?php echo $this->translate('community')->__("Write review for %s", $review['product_name']) ?>"
        ><span><?php echo $this->translate('community')->__("Write review") ?></span></a>
        <?php else: ?>
        <a href="<?php echo $this->href('review/login') ?>"
            rel="nofollow"
            title="<?php echo $this->translate('community')->__("Log in to write a review") ?>"
        ><span><?php echo $this->translate('community')->__("Log in to write a review") ?></span></a>
        <?php endif ?>
    </div>
    <div class="review-info">
        <a href="<?php echo $productUrl ?>"
            class="product-name"
            title="<?php echo $this->translate('community')->__("Read about %s", $review['product_name']) ?>"
        ><?php echo $review['product_name'] ?></a>
        <a href="<?php echo $this->href("review/product/{$review['product_key_word']}") ?>"
            title="<?php echo $this->translate('community')->__("View all reviews for %s", $review['product_name']) ?>"
        ><small><?php echo $this->translate('community')->__("View all reviews") ?></small></a>
        <span class="review-date"><small><?php echo $this->translate('community')->__("Reviewed on %s by %s", $review['date_created'], $author) ?></small></span>
        <h5 class="review-title"><a href="<?php echo $this->href("review/detail/id/{$review['id']}") ?>" title="Read review"><?php echo $review['title'] ?></a></h5>
        <?php if (isset($review['ratings'])): ?>
            <?php echo $this->ratings($review['ratings'], $this->href("review/detail/id/{$review['id']}")) ?>
        <?php endif ?>
        <p class="review-pros"><strong><?php echo $this->translate('community')->__("Pros") . ': ' ?></strong><?php echo nl2br($this->escape($review['pros'])) ?></p>
        <p class="review-cons"><strong><?php echo $this->translate('community')->__("Cons") . ': ' ?></strong><?php echo nl2br($this->escape($review['cons'])) ?></p>
        <p class="review-summary"><strong><?php echo $this->translate('community')->__("Summary") . ': ' ?></strong><?php echo nl2br($this->escape($review['summary'])) ?></p>
    </div>
</li>
<?php endforeach; ?>
</ol>
</form>
<?php echo $this->render('review/list/toolbar.phtml') ?>
<?php else: 
    echo $this->translate('community')->__("Review not found");
endif;?>